

<div class="layui-form" lay-filter="layuiadmin-form-admin" style="padding: 20px 30px 0 0;">
  <div class="layui-form-item">
    <label class="layui-form-label">姓名</label>
    <div class="layui-input-inline">
      <script type="text/html" template>
        <input type="text" name="name" id="name" value="{{ d.params.name || '' }}" lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input">
      </script>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">反馈内容</label>
    <div class="layui-input-inline">
      <script type="text/html" template>
        <textarea name="feedback_content" id="feedback_content" placeholder="请输入反馈内容" class="layui-textarea">{{ d.params.feedback_content || '' }}</textarea>
      </script>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">所属分类</label>
    <div class="layui-input-inline">
        <select name="add_problem_cate_id" id="add_problem_cate_id">
        </select>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">所属软件产品</label>
    <div class="layui-input-inline">
        <select name="add_software_product_id" id="add_software_product_id">
        </select>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">联系方式</label>
    <div class="layui-input-inline">
      <script type="text/html" template>
        <input type="text" name="mobile" id="mobile" value="{{ d.params.mobile || '' }}" lay-verify="required" placeholder="请输入联系方式" autocomplete="off" class="layui-input">
      </script>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">反馈紧急度</label>
    <div class="layui-input-block">
      <input type="radio" name="urgent" value="1" title="一般" checked>
      <input type="radio" name="urgent" value="2" title="紧急">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">图片</label>
    <div class="layui-input-inline">
      <script type="text/html" template>
        <input type="text" name="image_urls" id="image_urls" value="{{ d.params.image_urls || '' }}" placeholder="请上传图片" autocomplete="off" class="layui-input" >
      </script>
    </div>
    <button style="float: left;" type="button" class="layui-btn" id="layuiadmin-upload-list">上传图片</button> 
  </div>
  <script type="text/html" template>
      <input type="hidden" name="id" id="id" value="{{ d.params.id || '' }}">
      <input type="hidden" name="cate_id" id="cate_id" value="{{ d.params.problem_cate_id || '' }}">
      <input type="hidden" name="product_id" id="product_id" value="{{ d.params.software_product_id || '' }}">
  </script>
  <div class="layui-form-item">
    <label class="layui-form-label"></label>
    <div class="layui-input-inline">
      <input type="button" lay-submit lay-filter="LAY-feedback-back-submit" value="确认" class="layui-btn">
    </div>
  </div>
</div>

<script>
layui.use(['admin', 'form', 'upload'], function(){
  var $ = layui.$
  ,admin = layui.admin
  ,view = layui.view
  ,table = layui.table
  ,form = layui.form
  ,upload = layui.upload;

  $.ajax({
      type:'post',
      url:layui.setter.apiUrl+'/admin/problem/find_problem_cate_list',
      data:'',
      dataType:'json',
      async:true,
      success:function(json){ 
        var problem_cate_id = $('#cate_id').val();
          var option = '<option value="">请选择</option>';  //默认值
          if(json.data.length > 0){
              for(var i=0;i<json.data.length;i++){ 
                  //循环获取返回值，并组装成html代码
                  if(problem_cate_id == json.data[i].id){
                    option +="<option value='"+json.data[i].id+"' selected>"+json.data[i].cate_name+"-"+json.data[i].sub_cate_name+"</option>";
                  }else{
                    option +="<option value='"+json.data[i].id+"'>"+json.data[i].cate_name+"-"+json.data[i].sub_cate_name+"</option>";
                  }
              }
          }
          $("#add_problem_cate_id").html(option);
          form.render('select');
      },
  });

  $.ajax({
      type:'post',
      url:layui.setter.apiUrl+'/admin/software_product/find_software_product_list',
      data:'',
      dataType:'json',
      async:true,
      success:function(json){ 
        var software_product_id = $('#product_id').val();
          var option = '<option value="">请选择</option>';  //默认值
          if(json.data.length > 0){
              for(var i=0;i<json.data.length;i++){ 
                  //循环获取返回值，并组装成html代码
                  if(software_product_id == json.data[i].id){
                    option +="<option value='"+json.data[i].id+"' selected>"+json.data[i].product_name+"</option>";
                  }else{
                    option +="<option value='"+json.data[i].id+"'>"+json.data[i].product_name+"</option>";
                  }
              }
          }
          $("#add_software_product_id").html(option);
          form.render('select');
      },
  });

  upload.render({
    elem: '#layuiadmin-upload-list'
    ,url: layui.setter.apiUrl+'/admin/common/upload_file'
    ,accept: 'images'
    ,method: 'get'
    ,acceptMime: 'image/*'
    ,done: function(res){
      $(this.item).prev("div").children("input").val(res.data.src)
    }
  });

})
</script>